package 数组0508.删除排序数组中的重复项0508;



import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

//服务器端
public class TopClimtDemo01 {
    public static void main(String[] args) {
        ServerSocket a=null;
        Socket s=null;
        InputStream is=null;
        ByteArrayOutputStream baos=null;
        try{
            //有一个服务器地址
            a=new ServerSocket(7879);
            //等待客户端连接
            s=a.accept();
            //读取信息
            is=s.getInputStream();
            //管道流
            baos=new ByteArrayOutputStream();
            byte[] b=new byte[1024];
            int len;
            while((len=is.read(b))!=-1){
                baos.write(b,0,len);

            }
            System.out.println(baos.toString());
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            if(baos!=null){
                try {
                    baos.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if(is!=null){
                try {
                    is.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if(s!=null){
                try {
                    s.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if(a!=null){
                try {
                    a.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

    }




}
